package com.example.springmvcdemo;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Q
 * @create 2025-05-22-13:43
 */
@RequestMapping("/request")
@RestController
public class RequestController {
    @RequestMapping("/param1")
    public String param1(String userName) {
        System.out.println("接收到的参数为：" + userName);
        return "接收到的参数为：" + userName;
    }
    @RequestMapping("/param2")
    public String param2(String userName,String passWord) {
        System.out.println("接收到的参数为userName: " + userName + ",passWord：" + passWord);
        return "接收到的参数为userName: " + userName + ",passWord：" + passWord;
    }
    @RequestMapping("/param3")
    public String param3(UserInfo userInfo) {
        System.out.println(userInfo.toString());
        return userInfo.toString();
    }
    @RequestMapping("/param4")
    public String param4(@RequestParam(value = "userName",required = false) String name, String passWord) {
        System.out.println("接收到的参数为name: " + name + ",passWord：" + passWord);
        return "接收到的参数为name: " + name + ",passWord：" + passWord;
    }
}
